void main()
{
	gl_FrontColor = gl_Color;
	gl_Position = ftransform();
	gl_TexCoord[0] = gl_MultiTexCoord0;
}

FRAGMENT

uniform sampler2D warp;
uniform sampler2D particles;
uniform sampler2D color;
uniform sampler2D shadow;
uniform float sw;
uniform float sh;
uniform float zoom;
uniform float wstrength;
uniform float motionblur;
uniform float brightness;
uniform float contrast;
void main()
{
	vec2 wrp = (texture2D(warp,gl_TexCoord[0].st).rg - 0.5)*2;
	wrp.x *= sw;
	wrp.y *= sh;
	wrp *= zoom * wstrength;

	vec4 w = texture2D(warp,gl_TexCoord[0].st);

	vec4 c = texture2D(color,gl_TexCoord[0].st+wrp);
	vec4 p = texture2D(particles,gl_TexCoord[0].st+wrp);
	vec4 s = texture2D(shadow,gl_TexCoord[0].st+wrp);
	

	c.r *= s.r*2;
	c.g *= s.g*2;
	c.b *= s.b*2;
	//c = c + s*0.2*c.a;
	c = c + p*p.a;

	c.rgb += brightness;
	c.r = pow(c.r,contrast);
	c.g = pow(c.g,contrast);
	c.b = pow(c.b,contrast);
	c.rgb -= brightness;
	gl_FragColor = vec4(c.rgb,motionblur);
}
